package com.taxsearch.controller.checkin;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.taxsearch.service.linsa.StatisticsService;
import com.taxsearch.util.DbUtil;
import com.taxsearch.util.Json;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



/**
 * 
 * @Title:StatisticsController
 * @Description: 统计查询控制器
 * @author 高敏
 * @version V1.0
 * @date 2018年8月22日
 */
@Controller
@RequestMapping("/HotelAndroid")
public class StatisticsController {
	private static Logger logger = Logger.getLogger(StatisticsController.class);
	@Resource
	private StatisticsService statisticsService;

	/**
	 * 查询季收入
	 * 
	 * @return
	 */
	@RequestMapping("/selectSeason.do")
	@ResponseBody
	public Json selectSeason(HttpServletRequest request) {
		Json json = new Json();
		try{
			//String hotelCode = "5101220047";
			String hotelCode = request.getParameter("hotelCode");
			
			DbUtil.setDb("1");
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("DJ_LVGUANDAIMA", hotelCode);
			List<HashMap<String, String>> list = statisticsService.selectSeason(map);
			logger.info("成功查询季收入！");
			json.setObj(list);
			json.setMsg("成功查询季收入！");
			json.setSuccess(true);
		}catch(Exception e){
			json.setMsg("服务器繁忙,请稍后再试！");
			json.setSuccess(false);
			logger.error("selectSeason.do-发生错误!!!!!!!!!!!!!!!!!!!!!!!!", e);
			e.printStackTrace();
		}
		return json;
	}
	
	/**
	 * 查询月收入
	 * 
	 * @return
	 */
	@RequestMapping("/selectMonth.do")
	@ResponseBody
	public Json selectMonth(HttpServletRequest request) {
		Json json = new Json();
		try{
			//String hotelCode = "5101220047";
			String hotelCode = request.getParameter("hotelCode");
			
			DbUtil.setDb("1");
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("DJ_LVGUANDAIMA", hotelCode);
			List<HashMap<String, String>> list = statisticsService.selectMonth(map);
			logger.info("成功查询月收入！");
			json.setObj(list);
			json.setMsg("成功查询月收入！");
			json.setSuccess(true);
		}catch(Exception e){
			json.setMsg("服务器繁忙,请稍后再试！");
			json.setSuccess(false);
			logger.error("selectMonth.do-发生错误!!!!!!!!!!!!!!!!!!!!!!!!", e);
			e.printStackTrace();
		}
		return json;
	}
	
	/**
	 * 查询周收入
	 * 
	 * @return
	 */
	@RequestMapping("/selectWeek.do")
	@ResponseBody
	public Json selectWeek(HttpServletRequest request) {
		Json json = new Json();
		try{
			//String hotelCode = "5101220047";
			String hotelCode = request.getParameter("hotelCode");
			
			DbUtil.setDb("1");
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("DJ_LVGUANDAIMA", hotelCode);
			List<HashMap<String, String>> list = statisticsService.selectWeek(map);
			logger.info("成功查询周收入！");
			json.setObj(list);
			json.setMsg("成功查询周收入！");
			json.setSuccess(true);
		}catch(Exception e){
			json.setMsg("服务器繁忙,请稍后再试！");
			json.setSuccess(false);
			logger.error("selectWeek.do-发生错误!!!!!!!!!!!!!!!!!!!!!!!!", e);
			e.printStackTrace();
		}
		return json;
	}
}
